﻿using CnBlogsClient.Global;
using CnBlogsClient.Interface;
using CnBlogsCore.Model;
using System;
using System.Collections.Generic;
using System.Text;
using Xamarin.Forms;

namespace CnBlogsClient.Services
{
    class NewsService : INewsService
    {
        public string GetNewsDetail(int id)
        {
            string token = DependencyService.Get<AuthConfig>().GetClientCredentialToken();
            string tokenType = DependencyService.Get<AuthConfig>().GetClientCredentialTokenType();

            return DependencyService.Get<CnBlogsCore.Interface.INewsService>().GetNewsDetail
                 (token, tokenType, id);
        }

        public List<News> GetRecentNews(int pageIndex, int pageSize)
        {
            string token = DependencyService.Get<AuthConfig>().GetClientCredentialToken();
            string tokenType = DependencyService.Get<AuthConfig>().GetClientCredentialTokenType();

            return DependencyService.Get<CnBlogsCore.Interface.INewsService>().GetRecentNews
                (token, tokenType, pageIndex, pageSize);
        }

        public List<News> GetRecommendedNews(int pageIndex, int pageSize)
        {
            string token = DependencyService.Get<AuthConfig>().GetClientCredentialToken();
            string tokenType = DependencyService.Get<AuthConfig>().GetClientCredentialTokenType();

            return DependencyService.Get<CnBlogsCore.Interface.INewsService>().GetRecommendedNews
                (token, tokenType, pageIndex, pageSize);
        }

        public List<News> GetWeekHotNews(int pageIndex, int pageSize)
        {
            string token = DependencyService.Get<AuthConfig>().GetClientCredentialToken();
            string tokenType = DependencyService.Get<AuthConfig>().GetClientCredentialTokenType();

            return DependencyService.Get<CnBlogsCore.Interface.INewsService>().GetWeekHotNews
                (token, tokenType, pageIndex, pageSize);
        }
    }
}
